﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NHibernate;
using System.Web;
namespace OreSystem.DAL
{
    public class DaoFactory
    {
        private static ISessionFactory sessionFactory = null;
        private static NHibernate.Cfg.Configuration cfg = null;
        public DaoFactory()
        {
        }
        public static ISessionFactory CreateSessionFactory()
        {
            string configPath = string.Empty;
            if (System.Web.HttpContext.Current == null)
            {
                configPath = @"Config/Hib.cfg.xml";
            }
            else
            {
                configPath = System.Web.HttpContext.Current.Server.MapPath("~/")+@"Config\Hib.cfg.xml";
            }
            if (cfg == null)
            {
                cfg = new NHibernate.Cfg.Configuration().Configure(configPath);
            }
            if (sessionFactory == null)
            {
                sessionFactory = cfg.BuildSessionFactory();
            }
            return sessionFactory;     
        }
       
    }
}
